const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
      orderList:{
        type:Array,
        value:[]
      },
      orderStatus:{
        type:Number,
        value:null
      }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    sendGoods(e){
      console.log(e.currentTarget.dataset.orderId)
     let currentStatus= this.properties.orderStatus
     const orderId = e.currentTarget.dataset.orderId
      let nextStatus = currentStatus+1
      let showMsg=null;
      console.log("currentStatus"+currentStatus)
      console.log("nextStatus"+nextStatus)
      if(currentStatus==1){
        showMsg="开始制作";
      }else if(currentStatus==2){
        showMsg="制作完成";
      }else if(currentStatus==3){
        showMsg="开始发货";
      }else if(currentStatus==4){
        showMsg="送达";
      }
      wx.showModal({
        title: '提示',
        content: '确定'+showMsg+'吗',
        success (res) {
          if (res.confirm) {
            //调用订单修改接口  修改状态
            app.wxRequest('POST', '/order/updateNextStatusByCurrentStatusAndOrderId'
            +'?orderId='+orderId+'&currentStatus='+currentStatus+'&nextStatus='+nextStatus, null, (res) => {
              console.log("res"+res.data)
              if (200 == res.code && res.data) {
                wx.showToast({  
                  title: showMsg+'成功',  
                  image: '/images//icon/sendGoods.png',  
                  duration: 2000,  
                  mask: true,  
                  success: function() {  
                    // 提示显示成功后的回调函数
                    this.onShow()
                  },  
                  fail: function() {  
                    // 提示显示失败后的回调函数  
                  }  
                });
              }else{
                app.showMsg(res.msg);
              }
            }, (err) => {
              app.showMsg(err.errMsg);
            })
          } else if (res.cancel) {
            
          }
        }
      })
       
    },
    handleScrollUpper(){
      wx.startPullDownRefresh({
        success: () => {
          setTimeout(() => {
            wx.stopPullDownRefresh();
          }, 2000);
        }
      })
    }
  },
  onShow(){
    console.log("onShow");
  },
  onLoad(options) {
    console.log("onLoad")
  }
})
